<?php
/*
Template Name: Blog
*/
if ($custom_use_more_quicktag) { global $more; } ?>

<div id="body_block" <?php echo webtreats_body_class(); ?>>
	
	<?php if($home_slider_page) { webtreats_header_slider_switcher($homepage_slider); } ?>
	
	<?php webtreats_teaser_text($post->ID); ?>
	
<div id="body_block_background">
	<div class="inner">
							
	<?php $breadcrumb_page_disable = get_post_meta($post->ID, 'breadcrumb_page_disable', true);
			if (!$breadcrumb_disable && !$breadcrumb_page_disable){ if (class_exists('simple_breadcrumb')) { $bc = new simple_breadcrumb; }} ?>

		<div id="main">
			<div class="content">
				
<?php 
$teaser_text = get_post_meta($post->ID, 'teaser_text', true);
if ($teaser_text == 'default' && $header_teaser == 'disable' || $teaser_text == 'disable'){ ?>
<?php echo webtreats_title($post->ID); ?>
<?php } ?>



<?php 
$id = $blog_page; $p = get_page($id);
$blog_page_content = apply_filters('the_content', $p->post_content);
if($blog_page_content) : ?>

<div class="entry">
<?php echo $blog_page_content; ?>
	<div class="clearboth"></div>
</div>

<?php endif; ?>


<?php
if(is_front_page()){
$paged = (get_query_var('page')) ? get_query_var('page') : 1;	
}else{
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;	
}
$exclude_blog_cats = preg_replace("!(\d)+!","-${0}$0", $blog_excludecats);
$query_string = "cat=".$exclude_blog_cats."&paged=$paged";
query_posts($query_string); ?>

<?php if(have_posts()) : while(have_posts()) : the_post(); ?>

<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
	<div class="blog_module">
		
		<?php webtreats_post_image(); ?>

		<h2 class="blog_header">
			<a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a>
			<span class="comment_bubble"><?php comments_popup_link('0', '1', '%'); ?></span>
		</h2>		

		<div class="entry">
			<?php
			if ($custom_use_more_quicktag) {
				$more = 0;
				the_content("Read More",false);
			}else{ 
				the_excerpt(); ?><a class="fancy_link read_more_link" href="<?php the_permalink(); ?>">Read More</a>
			<?php } ?>
		</div>

		<div class="blog_meta">
			<?php $get_year = get_the_time('Y'); $get_month = get_the_time('m'); ?>
			Posted on: <a href="<?php echo get_month_link($get_year, $get_month); ?>"><?php the_time('m-j-Y') ?></a><br />
			Posted in: <?php the_category(', ') ?>
		</div>

	</div><!-- blog_module -->
</div><!-- post -->

<?php endwhile; ?>

<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
	
<?php else : ?>

	<p>Sorry, that document can not be found.</p>

<?php endif; ?>

<?php if($get_template == 'template-full.php') { echo '</div></div>'; }else{ get_sidebar(); } ?>
<?php get_footer(); ?>